/*function createAreaPick(callback,check=[0,0,0],level=3){
	var pickArr = [];
	
	var swiperHtml = '';
	
	for(let i=0;i<level;i++){
		let slideHtml = '';
		swiperHtml += `
			<div class="swiper-container level-${i+1} flex-full">
				<div class="swiper-wrapper">
					${
						(function(){
							for(let j=0;j<18;j++){
								if(i==0){
									slideHtml += `<div class="swiper-slide">一级分类${j}</div>`;
								}else if(i==1){
									slideHtml += `<div class="swiper-slide">二级分类${j}</div>`;
								}else{
									slideHtml += `<div class="swiper-slide">三级分类${j}</div>`;
								};
							};
							return slideHtml;
						})()
					}
				</div>
			</div>
		`;
	};
	
	$("body").append(`
		<div id="areaMask">
			<div class="dm-mask"></div>
			<div class="dm-picker">
				<div class="picker-header bottom-line">
					<a class="dm-left cancel">取消</a>
					<a class="dm-right enter">确定</a>
				</div>
				<div class="picker-mod flex-row">
					${swiperHtml}
				</div>
			</div>
		</div>	
	`);
	
	
	for(let i=0;i<level;i++){
		var mySwiper = new Swiper('.dm-picker .level-'+(i+1),{
			direction : 'vertical',
			slidesPerView:5,
			centeredSlides:true,
			effect: 'coverflow',
			observer:true,
			initialSlide: check[i],
			coverflowEffect: {
			    rotate: 7,
			    stretch:-10,
			    depth: 100,
			    slideShadows: false
			}
		});
		pickArr.push(mySwiper);
	};
	
	//关闭
	function closeArea(){
		$('#areaMask').fadeOut(function(){
			$('#areaMask').remove();
		});
	};
	
	//关闭
	$('#areaMask .cancel').click(function(){
		closeArea()
	});
	
	//确定
	$('#areaMask .enter').click(function(){
		let arr = [];
		for(i in pickArr){
			arr.push(pickArr[i].activeIndex);
		};
		if(typeof callback == 'function'){
			callback(arr);
		};
		closeArea();
	});
	
};*/




//商品分类筛选
function createAreaPick(callback,data,check=[0,0],level=2){
	var pickArr = [];
	
	var swiperHtml = '';
	
	for(let i=0;i<level;i++){
		let slideHtml = '';
		swiperHtml += `
			<div class="swiper-container level-${i+1} flex-full">
				<div class="swiper-wrapper">
					${
						(function(){
							if(i == 0){
								for(let j=0;j<data.length;j++){
									slideHtml += `<div class="swiper-slide">${data[j].name}</div>`;
								};
							}else{
								for(let j=0;j<data[check[0]].sub.length;j++){
									slideHtml += `<div class="swiper-slide">${data[check[0]].sub[j]}</div>`;
								};
							};
							return slideHtml;
						})()
					}
				</div>
			</div>
		`;
	};
	
	$("body").append(`
		<div id="areaMask">
			<div class="dm-mask"></div>
			<div class="dm-picker">
				<div class="picker-header bottom-line">
					<a class="dm-left cancel">取消</a>
					<a class="dm-right enter">确定</a>
				</div>
				<div class="picker-mod flex-row">
					${swiperHtml}
				</div>
			</div>
		</div>	
	`);
	
	
	for(let i=0;i<level;i++){
		var mySwiper = new Swiper('.dm-picker .level-'+(i+1),{
			direction : 'vertical',
			slidesPerView:5,
			centeredSlides:true,
			effect: 'coverflow',
			observer:true,
			initialSlide: check[i],
			coverflowEffect: {
			    rotate: 7,
			    stretch:-10,
			    depth: 100,
			    slideShadows: false
			},
		});
		pickArr.push(mySwiper);
	};
	
//	切换时
	pickArr[0].on('slideChange',function(){
		var html = '';
		var index = pickArr[0].activeIndex;
		console.log(index);
		$(".level-2 .swiper-wrapper").html(`
			${
				(function(){
					for(let i=0;i<data[index].sub.length;i++){
						html += `<div class="swiper-slide">${data[index].sub[i]}</div>`;
					};
					return html;
				})()
			}
		`);
		pickArr[1].init();
		pickArr[1].slideTo(0, 0, false);
	});
	
	//关闭
	function closeArea(){
		$('#areaMask').fadeOut(function(){
			$('#areaMask').remove();
		});
	};
	
	//关闭
	$('#areaMask .cancel').click(function(){
		closeArea()
	});
	
	//确定
	$('#areaMask .enter').click(function(){
		let arr = [];
		for(i in pickArr){
			arr.push(pickArr[i].activeIndex);
		};
		if(typeof callback == 'function'){
			callback(arr);
		};
		closeArea();
	});
	
};

